package org.jeecg.prod.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
import org.jeecg.prod.dto.MesWoSrcDTO;
import org.jeecg.prod.entity.MesWoSrc;
import org.jeecg.prod.mapper.MesWoSrcMapper;
import org.jeecg.prod.service.IMesWoSrcService;
import org.springframework.stereotype.Service;

/**
 * @Description: 工单管理
 * @Author: LiCY
 * @Date: 2023-06-16
 * @Version: V1.0
 */
@Service
public class MesWoSrcServiceImpl extends MppServiceImpl<MesWoSrcMapper, MesWoSrc> implements IMesWoSrcService {

    @Override
    public IPage<MesWoSrcDTO> queryPageList(Page<MesWoSrc> page, MesWoSrcDTO mesWoSrc) {
        return baseMapper.queryPageList(page, mesWoSrc);
    }

    @Override
    public IPage<MesWoSrcDTO> queryCountPageList(Page<MesWoSrc> page, MesWoSrcDTO mesWoSrc) {
        IPage<MesWoSrcDTO> mesWoSrcDTOIPage = baseMapper.queryPageList(page, mesWoSrc);
        mesWoSrcDTOIPage.getRecords().forEach(item->{
            //查询包装工位
            String op = baseMapper.getOPByWoId(item.getWoid());
            //查询数量
            MesWoSrcDTO orderData = baseMapper.getOrderData(item.getWoid(), op);
            item.setOutputNum(orderData.getOutputNum());
            item.setFirstPieceDate(orderData.getFirstPieceDate());
            item.setLastPieceDate(orderData.getLastPieceDate());
        });
        return mesWoSrcDTOIPage;
    }
}
